# Virtual Router Simulator 
#
# Copyright (C) 2009-2010 VRSim Project
# Author: Choonho Son <choonho@kt.com>
# URL: <http://vrsim.googlecode.com>
# For license information, see LICENSE.TXT
#

import sys,  os

###########
# Version
###########
(MAJOR,  MINOR,  SUB,  RCVER) = (1, 1,  0,  0)
INTVER =  MAJOR * 10000 + MINOR * 100 + SUB + RCVER
STRVER = "%s.%s.%s-RC%s" % (MAJOR,  MINOR,  SUB,  RCVER)
#STRVER = "0.1.0-RC1"


# Project save file
baseDir = "~/"
saveFilename = ""
addingLinkFlag = False
debugLevel = 2

# Base location of simulation
# where each eqipments exist
baseLocation = {"Korea": [37.0, 126.0], 
                "USA": [200,  300]}
                
GApp = None



###############################
# VMAPIMon
# Heart bit interval (second)
###############################
heartbit_interval = 20
BASEDIR = "/data"
USERID = "tester"
IMG_C7200 = "c7200-adventerprisek9-mz.124-20.T.bin"
IMG_C3600 = "c3640-js-mz.124-25.bin"
IMG_M40 = "JUNOS-9.0R1.10.img"
IMG_LINUX = "ubuntu9-04.img"
IMG_WINDOWSXP = "windowsxp.img"

class Enum:
    
    class LinkType:
        #Manual = 0
        Ethernet = 1
        FastEthernet = 2
        GigaEthernet = 3
        #Serial = 4
        #ATM = 5
        #POS = 6

linkTypes = {
            #'Manual': Enum.LinkType.Manual, 
            'Ethernet': Enum.LinkType.Ethernet, 
            'FastEthernet': Enum.LinkType.FastEthernet, 
            'GigaEthernet': Enum.LinkType.GigaEthernet,
             #'Serial': Enum.LinkType.Serial, 
             #'ATM': Enum.LinkType.ATM, 
             
             #'POS': Enum.LinkType.POS
}

linkTypes_string = {
                    0 : "Manual", 
                    1 : "Ethernet", 
                    2 : "FastEthernet", 
                    3 : "GigaEthernet", 
                    4 : "Serial", 
                    5 : "ATM", 
                    6 : "POS", 
                    }
bandWidth = {
             Enum.LinkType.Ethernet: "E", 
             Enum.LinkType.FastEthernet: "FE", 
             Enum.LinkType.GigaEthernet: "GE", 
             }
             
currentLinkType = Enum.LinkType.Ethernet
####################
# Adapter name
####################
class Adapter:
    rtl8139 = "rtl8139"
    i81559er = "i81559er"
    e1000 = "e1000"
    C7200_IO_2FE = "C7200-IO-2FE"
    C7200_IO_GE="C7200-IO-GE-E"
    PA_2FE_TX = "PA-2FE-TX"
    PA_4E = "PA-4E"
    PA_8E = "PA-8E"
    PA_GE = "PA-GE"
    
    MaxInterface = {"rtl8139": 1, 
                    "i81559er" : 1, 
                    "e1000" : 1, 
                    "C7200_IO_2FE": 2,  
                    "C7200_IO_GE_E": 1, 
                    "PA-2FE-TX": 2, 
                    "PA-4E" : 4, 
                    "PA-8E" : 8, 
                    "PA-GE" : 1
                    }
    
# slot : [slot model, possible if name]
qemu_ethernet_slot = {
                        'slot 0': ['fxp 0'], 
                        'slot 1': ['fxp 1'], 
                        'slot 2': ['fxp 2'], 
                        'slot 3': ['fxp 3'], 
                        'slot 4': ['fxp 4'], 
                        'slot 5': ['fxp 5'], 
                        'slot 6': ['fxp 6'], 
                        'slot 7': ['fxp 7'], 
                        
                     }
                     
qemu_fastethernet_slot = qemu_ethernet_slot
        
qemu_gigaethernet_slot = {
                        'slot 0':['em 0'], 
                        'slot 1': ['em 1'], 
                        'slot 2': ['em 2'], 
                        'slot 3': ['em 3'], 
                        'slot 4': ['em 4'], 
                        'slot 5': ['em 5'], 
                        'slot 6': ['em 6'], 
                        'slot 7': ['em 7'], 
                        
                     }

qemu_window_slot = {
                    'slot 0': ['eth 0'], 
                    }

cisco_ethernet_slot = { 
                        'slot 0': [], 
                        'slot 1': ['E 1/0',  'E 1/1',  'E 1/2',  'E 1/3',  'E 1/4',  'E 1/5',  'E 1/6',  'E 1/7',  'E 1/8',  'E 1/9',  'E 1/10',  'E 1/11',  'E 1/12',  'E 1/13',  'E 1/14',  'E 1/15'], 
                        'slot 2': ['E 2/0',  'E 2/1',  'E 2/2',  'E 2/3',  'E 2/4',  'E 2/5',  'E 2/6',  'E 2/7',  'E 2/8',  'E 2/9',  'E 2/10',  'E 2/11',  'E 2/12',  'E 2/13',  'E 2/14',  'E 2/15'], 
                        'slot 3': ['E 3/0',  'E 3/1',  'E 3/2',  'E 3/3',  'E 3/4',  'E 3/5',  'E 3/6',  'E 3/7',  'E 3/8',  'E 3/9',  'E 3/10',  'E 3/11',  'E 3/12',  'E 3/13',  'E 3/14',  'E 3/15'], 
                        'slot 4': ['E 4/0',  'E 4/1',  'E 4/2',  'E 4/3',  'E 4/4',  'E 4/5',  'E 4/6',  'E 4/7'], 
                        'slot 5': ['E 5/0',  'E 5/1',  'E 5/2',  'E 5/3',  'E 5/4',  'E 5/5',  'E 5/6',  'E 5/7'], 
                        'slot 6': ['E 6/0',  'E 6/1',  'E 6/2',  'E 6/3',  'E 6/4',  'E 6/5',  'E 6/6',  'E 6/7'], 
                    }
   
cisco_fastethernet_slot = { 
                        'slot 0': ['FE 0/0', 'FE 0/1'], 
                        'slot 1': ['FE 1/0',  'FE 1/1',  'FE 1/2',  'FE 1/3',  'FE 1/4',  'FE 1/5',  'FE 1/6',  'FE 1/7',  'FE 1/8',  'FE 1/9',  'FE 1/10',  'FE 1/11',  'FE 1/12',  'FE 1/13',  'FE 1/14',  'FE 1/15'], 
                        'slot 2': ['FE 2/0',  'FE 2/1',  'FE 2/2',  'FE 2/3',  'FE 2/4',  'FE 2/5',  'FE 2/6',  'FE 2/7',  'FE 2/8',  'FE 2/9',  'FE 2/10',  'FE 2/11',  'FE 2/12',  'FE 2/13',  'FE 2/14',  'FE 2/15'], 
                        'slot 3': ['FE 3/0',  'FE 3/1',  'FE 3/2',  'FE 3/3',  'FE 3/4',  'FE 3/5',  'FE 3/6',  'FE 3/7',  'FE 3/8',  'FE 3/9',  'FE 3/10',  'FE 3/11',  'FE 3/12',  'FE 3/13',  'FE 3/14',  'FE 3/15'], 
                        'slot 4': ['FE 4/0',  'FE 4/1',  'FE 4/2',  'FE 4/3',  'FE 4/4',  'FE 4/5',  'FE 4/6',  'FE 4/7'], 
                        'slot 5': ['FE 5/0',  'FE 5/1',  'FE 5/2',  'FE 5/3',  'FE 5/4',  'FE 5/5',  'FE 5/6',  'FE 5/7'], 
                        'slot 6': ['FE 6/0',  'FE 6/1',  'FE 6/2',  'FE 6/3',  'FE 6/4',  'FE 6/5',  'FE 6/6',  'FE 6/7'], 
                    }
     
#cisco_fastethernet_slot = { 
#                        'slot 0': ['FE 0/0',  'FE 0/1'], 
#                        'slot 1': ['FE 1/0',  'FE 1/1'], 
#                        'slot 2': ['FE 2/0',  'FE 2/1'], 
#                        'slot 3': ['FE 3/0',  'FE 3/1'], 
#                        'slot 4': ['FE 4/0',  'FE 4/1'], 
#                        'slot 5': ['FE 5/0',  'FE 5/1'], 
#                        'slot 6': ['FE 6/0',  'FE 6/1'], 
#                    }
                
cisco_gigaethernet_slot = {
                        'slot 0': ['GE 0/0'], 
                        'slot 1': ['GE 1/0'], 
                        'slot 2': ['GE 2/0'], 
                        'slot 3': ['GE 3/0'], 
                        'slot 4': ['GE 4/0'], 
                        'slot 5': ['GE 5/0'], 
                        'slot 6': ['GE 6/0'], 
                    }
                     
###################
# UDP socket binding
###################
binding_port = 10000
already_binding_port = []
dynamips_console = 7000
instantID = 0

###################
# Physical Node State
###################
START = "Running"
STOP = "Stoped"
SUSPEND = "Suspended"
UNKNOWN = "Unknown"

###################
# Image Files
###################
junos_img_list = ["/data/junos_9_0.img", 
                        "/data/junos_8_5.img", 
                  ]
junos_9_0 = "/data/junos_9_0.img"

###################
# QEMU NIC  Type
###################
nic_model = ['None', 'socket']


###################
# user config
###################
#user_directory = '/data/testbed'
working_directory = '/data/testbed'
VNC = "C:/Python26/Lib/site-packages/VRSim/vnc-viewer.exe"
VNC_LINUX = "/usr/bin/vncviewer"

TERMINAL = ""
TERMINAL_WIN = "C:/Python26/Lib/site-packages/VRSim/putty.exe"
TERMINAL_WIN_TERATERM = "C:/Program Files/teraterm/ttermpro.exe"
TERMINAL_LINUX = "/usr/bin/xterm"
DIR_DELIMETER = "/"
ENCODING = "utf-8"
DECODING = "utf-8"
if sys.platform.startswith("win"):
    if os.path.exists(TERMINAL_WIN_TERATERM):
        TERMINAL = TERMINAL_WIN_TERATERM
    else:
        TERMINAL = TERMINAL_WIN
    DIR_DELIMETER = "/"
    ENCODING = "euc-kr"
else:
    TERMINAL = TERMINAL_LINUX
    DIR_DELIMETER = "/"
    ENCODING = "utf-8"
    VNC = VNC_LINUX

####################
# Event Message
####################
eventMsg = {
            "loadXML"       : "Loading a project file(%s)", 
           "addNode"        : "Add Node: %s", 
           "deleteNode"     : "Delete Node: %s", 
           "addLink"          : "Add Link between %s and %s", 
           "deleteLink"       : "Delete Link between %s and %s", 
           "start"      : "Start Node: %s", 
           "stop"       : "Stop Node: %s", 
           "suspend" : "Suspend Node: %s", 
           "changeToReal" : "Change Node %s to Real Node Instance", 
           "changeToVirtual" : "Change Node %s to Virtual Node Instance", 
           "changeHostname" : "Change Hostname %s to %s",  
            "login"            : "User ID(%s) is accepted", 
            "updateVMAPI"   : "VMAPI(%s) is connected", 
            "__action_save" : "Save project file(%s)", 
            "__action_saveas": "Save project file as (%s)", 
            "getResource" : "Receive resource information from (%s)", 
            }
errorMsg = {
            "login"         : "User ID(%s) is not correct!", 
            "udpateVMAPI"   : "VMAPI(%s) is not connected!", 
            "__action_save" : "Can not save file(%s)",  
            "__action_saveas": "Can not save project file as (%s)", 
            "getResource" : "Can not receive resource information from (%s)", 
            "start" : "Can not start Node(%s), ask server manager", 
            "stop" : "Can not stop Node(%s), ask server manager", 
            "suspend" : "Can not suspend Node(%s), ask server manager", 
            "defineXML" : "Can not define domain(%s)", 
            }
err = ""

#########################
# COLOR
#########################
IfnameColor = "blue"
